
//函数类型
function add(num1: number, num2: number): number {
    return num1 + num2
}
const add2 = (num1: number, num2: number): number => {
    return num1 + num2
}
const add3: (num1: number, num2: number) => number = (num1, num2) => {
    return num1 + num2
}

//无返回值函数
function greet(name: string): void {
    console.log('hello', name)
}

//可选参数
function mySlice(start?: number, end?: number): void {
    console.log('起始索引:', start, '结束索引', end)
}

mySlice()
mySlice(1)
mySlice(1, 3)
